/*
 createRouter： 用于创建router实例
 RouteRecordRaw：用于规范路由规则 增强路由对象类型限制
 createWebHashHistory: 实用hash路由模式
*/
import { createRouter, RouteRecordRaw, createWebHashHistory } from 'vue-router'
import { userStore } from '../store/user'
// 配置路由规则
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: () => import('/@/views/homeView.vue')
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHashHistory(),
  routes
})
// 路由导航守卫
router.beforeEach((to, from, next) => {
  const store = userStore()
  if (store.token) {
    next()
  }
})

export default router
